package com.web.pojo.vo;

import com.web.utils.ToolUtil;

import java.io.Serializable;
import java.util.Arrays;

/**
 * @Author: wws
 * describe:
 */
public class GetSwitchDeviceAttributesVO implements Serializable {

    private Integer deviceId;
    private Float temperature;//开关温度
    private Float humidity;//开关湿度
    private Float dewPoint;//开关露点
    private Byte battery;//开关电源/电池量
    private Byte deviceStatus;//设备状态

    public GetSwitchDeviceAttributesVO() {
    }


    public GetSwitchDeviceAttributesVO(Integer deviceId, byte[] deviceResult) {
        this.deviceId = deviceId;
        this.temperature = ToolUtil.bytesToFloat(Arrays.copyOfRange(deviceResult, 5, 9));
        this.humidity = ToolUtil.bytesToFloat(Arrays.copyOfRange(deviceResult, 9, 13));
        this.dewPoint = ToolUtil.bytesToFloat(Arrays.copyOfRange(deviceResult, 13, 17));
        this.battery = deviceResult[17];
        this.deviceStatus = deviceResult[18];
    }

    public GetSwitchDeviceAttributesVO(Integer deviceId, Float temperature, Float humidity, Float dewPoint, Byte battery, Byte deviceStatus) {
        this.deviceId = deviceId;
        this.temperature = temperature;
        this.humidity = humidity;
        this.dewPoint = dewPoint;
        this.battery = battery;
        this.deviceStatus = deviceStatus;
    }

    public Integer getDeviceId() {
        return deviceId;
    }

    public void setDeviceId(Integer deviceId) {
        this.deviceId = deviceId;
    }

    public Float getTemperature() {
        return temperature;
    }

    public void setTemperature(Float temperature) {
        this.temperature = temperature;
    }

    public Float getHumidity() {
        return humidity;
    }

    public void setHumidity(Float humidity) {
        this.humidity = humidity;
    }

    public Float getDewPoint() {
        return dewPoint;
    }

    public void setDewPoint(Float dewPoint) {
        this.dewPoint = dewPoint;
    }

    public Byte getBattery() {
        return battery;
    }

    public void setBattery(Byte battery) {
        this.battery = battery;
    }

    public Byte getDeviceStatus() {
        return deviceStatus;
    }

    public void setDeviceStatus(Byte deviceStatus) {
        this.deviceStatus = deviceStatus;
    }

    @Override
    public String toString() {
        return "GetSwitchDeviceAttributesVO{" +
                "deviceId=" + deviceId +
                ", temperature=" + temperature +
                ", humidity=" + humidity +
                ", dewPoint=" + dewPoint +
                ", battery=" + battery +
                ", deviceStatus=" + deviceStatus +
                '}';
    }
}
